/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package EL;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

/**
 *
 * @author Tian
 */
@Entity
@Table(name = "Restaurant")
@NamedQueries(
{
    @NamedQuery(name = "Restaurants.findAll", query = "SELECT r FROM Restaurants r")
})
public class Restaurants implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue (strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "name")
    private String name;
    @Column(name = "imgPath")
    private String imgPath;
    @OneToMany(mappedBy = "restaurants")
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<DiningRooms> diningRoomsList;
    @JoinColumn(name = "contactID", referencedColumnName = "id")
    @OneToOne
    private Contacts contacts;

    public Restaurants()
    {
    }

    public Restaurants(String name, String imgPath)
    {
        this.name = name;
        this.imgPath = imgPath;
    }

    public Restaurants(Integer id)
    {
        this.id = id;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getImgPath()
    {
        return imgPath;
    }

    public void setImgPath(String imgPath)
    {
        this.imgPath = imgPath;
    }

    public List<DiningRooms> getDiningRoomsList()
    {
        return diningRoomsList;
    }

    public void setDiningRoomsList(List<DiningRooms> diningRoomsList)
    {
        this.diningRoomsList = diningRoomsList;
    }

    public Contacts getContacts()
    {
        return contacts;
    }

    public void setContacts(Contacts contacts)
    {
        this.contacts = contacts;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Restaurants))
        {
            return false;
        }
        Restaurants other = (Restaurants) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "EL.Restaurants[id=" + id + "]";
    }

}
